package c.m.d.b.rest.beans;

import c.m.d.b.exception.CMDBException;
import c.m.d.b.util.Utils;

import java.util.Arrays;
import java.util.Collection;


public final class IdList
{
    private String[] ids;

    public IdList()
    {
    }

    public IdList(String listStr)
    {
        ids = splitString(listStr);
    }

    //    public IdList(String[] ids)
//    {
//        this.ids = ids;
//    }
//
//    public void setIds(String[] ids)
//    {
//        this.ids = ids;
//    }
//
    static String[] splitString(String str)
    {
        if (Utils.isEmpty(str))
        {
            throw new CMDBException(CMDBException.CMDBErrorCode.BAD_REQUEST);
        }
        return str.trim().split(",");
    }

    public String[] getIds()
    {
        return ids;
    }

    public Collection<String> asCollection()
    {
        return Arrays.asList(getIds());
    }

}


